]> git.r.bdr.sh - rbdr/Flat-Bezel.qsplugin/blob - Flat Bezel/BBFlatBezelInterface.m
Add build files
[rbdr/Flat-Bezel.qsplugin] / Flat Bezel / BBFlatBezelInterface.m
1 #import "BBFlatBezelInterface.h"
2
3 @interface BBFlatBezelInterface () {
4 CGRect initialRect;
5 }
6 @end
7
8 @implementation BBFlatBezelInterface
9
10 - (id)init {
11 return [self initWithWindowNibName:@"BBFlatBezelInterface"];
12 }
13
14 - (void)windowDidLoad {
15 initialRect = centerRectInRect([[self window] frame], [[NSScreen mainScreen] frame]);
16
17 [super windowDidLoad];
18
19 QSWindow *window = (QSWindow *)[self window];
20 [window setLevel:NSPopUpMenuWindowLevel];
21 [window setBackgroundColor:[NSColor clearColor]];
22 [window setOpaque:NO];
23
24 [window setHideOffset:NSMakePoint(0, 0)];
25 [window setShowOffset:NSMakePoint(0, 0)];
26
27 [window setMovableByWindowBackground:NO];
28 [window setFastShow:YES];
29 [window setHasShadow:YES];
30
31 [window setFrame:standardRect display:YES];
32
33 NSArray *theControls = [NSArray arrayWithObjects:dSelector, aSelector, iSelector, nil];
34 for(QSSearchObjectView *theControl in theControls) {
35 QSObjectCell *theCell = [theControl cell];
36
37 [theControl setPreferredEdge:NSMinYEdge];
38 [(QSWindow *)[(theControl)->resultController window] setHideOffset:NSMakePoint(0, NSMinY([iSelector frame]))];
39 [(QSWindow *)[(theControl)->resultController window] setShowOffset:NSMakePoint(0, NSMinY([dSelector frame]))];
40
41 [theCell setBackgroundColor:[NSColor clearColor]];
42 [theCell setFont:[NSFont systemFontOfSize:11 weight:NSFontWeightLight]];
43 [theCell setCellRadiusFactor:4];
44
45 [theCell setHighlightColor:[NSColor colorWithRed:1 green:1 blue:1 alpha:.15]];
46 [theCell setTextColor:[NSColor textColor]];
47 [theCell setShowDetails:NO];
48 [theCell setState:NSControlStateValueOn];
49 [theCell setIconSize:QSSize128];
50 [theCell setImagePosition:NSImageAbove];
51 }
52
53 [self contractWindow:nil];
54 }
55
56 - (NSSize) maxIconSize {
57 return QSSize32;
58 }
59
60 - (void)showMainWindow:(id)sender {
61 [[self window] setFrame:[self rectForState:[self expanded]] display:YES];
62 if ([[self window] isVisible]) [[self window] pulse:self];
63 [super showMainWindow:sender];
64 // Does this need to be here?
65 [[[self window] contentView] setNeedsDisplay:YES];
66 }
67
68 - (void)expandWindow:(id)sender {
69 if (![self expanded])
70 [[self window] setFrame:[self rectForState:YES] display:YES animate:YES];
71 [super expandWindow:sender];
72 }
73
74 - (void)contractWindow:(id)sender {
75 if ([self expanded])
76 [[self window] setFrame:[self rectForState:NO] display:YES animate:YES];
77 [super contractWindow:sender];
78 }
79
80 - (NSRect)rectForState:(BOOL)shouldExpand {
81 NSRect newRect = initialRect;
82 NSRect screenRect = [[NSScreen mainScreen] frame];
83
84 if (!shouldExpand) {
85 newRect.size.width -= 192;
86 }
87
88 return NSOffsetRect(centerRectInRect(newRect, screenRect), 0, (NSHeight(screenRect) / 5));
89 }
90
91 - (NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *)sheet usingRect:(NSRect)rect {
92 return NSOffsetRect(NSInsetRect(rect, 8, 0), 0, 0);
93 }
94
95 - (NSTimeInterval)animationResizeTime:(NSRect)newWindowFrame {
96 return 0.01;
97 }
98
99 @end